<template>
  <div>
    <a-table bordered :data-source="dataSource" :columns="columns">
      <template slot="operation" slot-scope="text, record">
        <a-popconfirm
          title="是否删除"
          @confirm="() => message_delete(record.task_id)"
        >
          <a href="Javascript:void(0)">已读</a>
        </a-popconfirm>
      </template>
    </a-table>
  </div>
</template>

<script>
import { get_message, delete_message } from "./axios_http/api";

export default {
  data() {
    return {
      // 列
      columns: [
        { title: "task_id", dataIndex: "task_id" },
        { title: "message", dataIndex: "message" },

        // 指定操作列
        {
          title: "operation",
          dataIndex: "operation",
          scopedSlots: { customRender: "operation" },
        },
      ],
      // 具体数据
      dataSource: [],
    };
  },
  methods: {
    message_delete(task_id) {
        console.log(task_id)
      delete_message({ data: { task_id: task_id } }).then((resp) => {
          console.log(resp)
          if(resp.code == 200){
            this.$message.info(resp.data);
            this.$router.go(0)
          }
      });
    },
  },
  created() {
    console.log(123445)
    get_message().then((resp) => {
      console.log(resp);
      this.dataSource = resp.data;
      console.log(this.scopedSlots);
    });
  },
};
</script>